<?php
/**
 * Created by PhpStorm.
 * User: 554665488
 * Date: 2018-6-26
 * Time: 14:26
 * @description:多端口监听
 * @Author: yfl
 * @QQ 554665488
 */
$http = new swoole_http_server('0.0.0.0', 9502);
$port = $http->addlistener('127.0.0.1', 9503, SWOOLE_SOCK_TCP);
$port->set([
    'worker_num' => 2, //设置工作进程
    'max_request' => 1000,
]);
$http->set([
    'package_max_length' => 1024 * 1024 * 2,
    'upload_tem_dir' => __DIR__ . '/upload'
]);
$http->on('request', function (\Swoole\Http\Request $request, \Swoole\Http\Response $response) {
    echo 'http';

    $response->end("<meta charset='UTF-8'>" . 'Http多端口监听');
});

$port->on('receive', function ($server, $fd, $from_id, $data) {
    echo 'tcp';
    var_dump($server->connection_info($fd));
//    $server->send($fd, '2');
});

$http->start();